import { createRouter, createWebHistory } from 'vue-router';
// @ts-ignore
import HomeView from '../views/Home/HomeView.vue';
// @ts-ignore
import LoginView from '../views/Login/LoginView.vue';
// @ts-ignore
import SpaceView from '../views/Space/SpaceView.vue';
// @ts-ignore
// import SpaceHome from '../views/Space/SpaceHome.vue'; // 主页
// @ts-ignore
import SpaceDetail from '../views/Space/SpaceDetail.vue'; // 详情页
// @ts-ignore
// import SpaceSettings from '../views/Space/SpaceSettings.vue'; // 空间设置
// @ts-ignore
import Admin from '../Admin.vue';
// @ts-ignore
import RedisAdmin from '../views/Admin/RedisAdmin.vue';
// @ts-ignore
import DictAdmin from '../views/Admin/DictAdmin.vue';
// @ts-ignore
import DictDetail from "@/views/Admin/DictDetail.vue";

// 创建路由
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView
    },
    {
      path: '/space',
      meta: { title: '空间管理', activeMenuName: 'spaceHome' },
      redirect: '/space/home',  // 默认重定向到 space 首页
      children: [
        {
          path: 'home',
          component: SpaceView,
          name: 'SpaceHome',
          meta: { title: '空间首页', activeMenuName: 'spaceHome' }
        },
        {
          path: 'demo',
          component: SpaceDetail,
          name: 'SpaceDetail',
          meta: { title: '空间详情', activeMenuName: 'spaceDetail' }
        },
        // {
        //   path: ':id',  // 动态路由，用于访问具体的空间
        //   component: SpaceDetail,
        //   name: 'SpaceDetailWithId',
        //   meta: { title: '空间详情', activeMenuName: 'spaceDetail' }
        // },
        // {
        //   path: 'settings',
        //   component: SpaceSettings,
        //   name: 'SpaceSettings',
        //   meta: { title: '空间设置', activeMenuName: 'spaceSettings' }
        // }
      ]
    },
    {
      path: '/about',
      name: 'about',
      // @ts-ignore
      component: () => import('../views/AboutView.vue')
    },
    {
      path: '/login',
      name: 'login',
      component: LoginView
    },
    {
      path: '/admin',
      meta: { title: '内部管理员平台', activeMenuName: 'adminHome' },
      redirect: '/admin/user',
      children: [
        { path: '', component: RedisAdmin },
        {
          path: 'redis',
          component: RedisAdmin,
          name: 'RedisAdmin',
          meta: { title: '缓存管理', activeMenuName: 'RedisAdmin' }
        },
        {
          path: 'dictionary',
          component: DictAdmin,
          name: 'DictAdmin',
          meta: { title: '字典管理', activeMenuName: 'dictAdmin' }
        },
        {
          path: 'dictionary/:id',
          component: DictDetail,
          name: 'DictDetail',
          meta: { title: '字典详情', activeMenuName: 'dictAdmin' }
        }
      ]
    }
  ]
});

export default router;
